/** @file    SecurityAuthentication3rdParty.cpp
 *  @author  Alessandro Polo
 *  @version $Id: SecurityAuthentication3rdParty.cpp 2732 2010-07-06 03:18:11Z alex $
 *  @brief
 * File containing methods for the wosh::security::SecurityAuthentication3rdParty class.
 * The header for this class can be found in SecurityAuthentication3rdParty.h, check that file
 * for class description.
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

 #include <framework/security/SecurityAuthentication3rdParty.h>

 #include <core/UserManager.h>
// #include <core/User.h>
 #include <core/ObjectAllocator.h>

using namespace std;
namespace wosh {
 namespace security {

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

 WOSH_REGISTER(wosh::security::SecurityToken3rdparty, "wosh::SecurityToken", _SecurityToken3rdparty_VERSION, _static_SecurityToken3rdparty)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

 WOSH_REGISTER(wosh::security::SecurityTokenProvider3rdparty, "wosh::SecurityTokenProvider", _SecurityToken3rdparty_VERSION, _static_SecurityTokenProvider3rdparty)

SecurityTokenProvider3rdparty::SecurityTokenProvider3rdparty()
	: SecurityTokenProvider() {
 }
SecurityTokenProvider3rdparty::SecurityTokenProvider3rdparty( const SecurityTokenProvider3rdparty& m )
	: SecurityTokenProvider(m) {
 }

WRESULT SecurityTokenProvider3rdparty::setAuthorityName( const std::string& a_name ) {
	this->data.authority_name = a_name;
	return WRET_OK;
 }

WRESULT SecurityTokenProvider3rdparty::setAuthorityChannel( SecurityTokenProvider3rdparty_ChannelType ch_type ) {
	this->data.type = static_cast<int>(ch_type);
	return WRET_OK;
 }

SecurityToken* SecurityTokenProvider3rdparty::createToken() const {
	SecurityToken3rdparty* st = new SecurityToken3rdparty();
	st->data = this->data;
	return st;
 }

SecurityToken3rdparty* SecurityTokenProvider3rdparty::createToken( const std::string& account_name ) const {
	SecurityToken3rdparty* st = new SecurityToken3rdparty();
	st->data = this->data;
	st->user_contact_id = account_name;
	return st;
 }

SecurityToken* SecurityTokenProvider3rdparty::signMessage( Message* message, const std::string& username, const std::string& account_name ) const {
	SecurityToken3rdparty* st = createToken(account_name);
	initToken(st);
	updateToken(st, username);
	finalizeSigning(st, message);
	return st;
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

 WOSH_REGISTER(wosh::security::SecurityTokenAuthenticator3rdparty, "wosh::SecurityTokenAuthenticator", _SecurityToken3rdparty_VERSION, _static_SecurityTokenAuthenticator3rdparty)

SecurityTokenAuthenticator3rdparty::SecurityTokenAuthenticator3rdparty()
	: SecurityTokenAuthenticator() {
 }
//SecurityTokenAuthenticator3rdparty::SecurityTokenAuthenticator3rdparty( const SecurityTokenAuthenticator3rdparty& m )
//	: SecurityTokenAuthenticator(m) {
// }

bool SecurityTokenAuthenticator3rdparty::isSupported( const char* provider_classname, double version ) const {
	if ( provider_classname == NULL ) return false;
	if ( strcmp(provider_classname, SecurityToken3rdparty::className()) != 0 ) return false;
	if ( version != 0.0 && version > _SecurityToken3rdparty_VERSION ) return false;
	return true;
 }

WRESULT SecurityTokenAuthenticator3rdparty::validateToken( const SecurityToken* token ) const {






	return WRET_ERR_INTERNAL;
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////


 

































/*

 //WOSH_REGISTER_INTERFACE(wosh::security::SecurityAuthentication3rdParty, "wosh::SecurityAuthentication", 1.0, _static_SecurityAuthentication3rdParty )
 WOSH_REGISTER(wosh::security::SecurityAuthentication3rdParty, "wosh::SecurityAuthentication", 1.0, _static_SecurityAuthentication3rdParty )

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////// CONSTRUCTORS

SecurityAuthentication3rdParty::SecurityAuthentication3rdParty()
	: SecurityAuthentication() {
	this->provider_name = "";
 }

SecurityAuthentication3rdParty::SecurityAuthentication3rdParty( const SecurityAuthentication3rdParty& m )
	: SecurityAuthentication(m) {
	this->provider_name = m.provider_name;
 }

//////////////////////////////////////////////////////////////////////////////////////////////// CONSTRUCTORS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

SecurityToken* SecurityAuthentication3rdParty::generateToken( const Object* object ) {
	if ( object == NULL ) return NULL;
	SecurityToken* st = NULL;

	return st;
 }

SecurityToken* SecurityAuthentication3rdParty::generateToken( const std::string& user, const Object* object ) {
	SecurityToken* st = NULL;

	return st;
 }

WRESULT SecurityAuthentication3rdParty::validateToken( const SecurityToken* token, const Object* object ) {
	if ( token == NULL ) return WRET_ERR_PARAM;
	if ( object == NULL ) return WRET_ERR_PARAM;

	return WRET_ERR_INTERNAL;
 }

WRESULT SecurityAuthentication3rdParty::validateToken( const SecurityToken* token, const std::string& user, const Object* object ) {
	if ( token == NULL ) return WRET_ERR_PARAM;

	return WRET_ERR_INTERNAL;
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

WRESULT SecurityAuthentication3rdParty::validate( const wosh::User* user ) const {
	return WRET_OK;
 }
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

 }; // namespace security
}; // namespace wosh
